﻿using Interface;
using Microsoft.AspNetCore.Mvc;

namespace CoreWeb.Controllers
{
    public class ThirdController : Controller
    {
        private readonly ILogger<ThirdController> _logger;
        private readonly ITestServiceA _itsA;
        private readonly ITestServiceB _itsB;
        private readonly ITestServiceC _itsC;
        private readonly ITestServiceD _itsD;
        private readonly ITestServiceE _itsE;
        ///为什么要用IOC
        ///1. 可以去掉对细节的依赖，方便扩展---减小影响范围，甚至转移到配置未见以来，只需要修改配置未见
        ///假如没有IOC--需要E-先构造C--构造B--构造A----上端需要所有细节
        ///2.可以做到屏蔽细节，对象依赖注入（DI）
        public ThirdController(ILogger<ThirdController> logger, ITestServiceA itsA, ITestServiceB itsB, ITestServiceC itsC, ITestServiceD itsD, ITestServiceE itsE)
        {
            _logger = logger;
            _itsA = itsA;
            _itsB = itsB;
            _itsC = itsC;
            _itsD = itsD;
            _itsE = itsE;
        }

        public IActionResult Index()
        {
            _itsA.Show();
            _itsB.Show();
            _itsC.Show();
            _itsD.Show();
            _itsE.Show();

            return View();
        }
    }
}
